package Day014_Lambda表达式_Stream流.ZuoYe.Test4;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author zhangyan
 * @date 2020/5/5 18:46
 */
public class Test5 {
    public static void main(String[] args) {
        //集合
        List<String> one = new ArrayList<>();
        one.add("陈玄风");
        one.add("梅超风");
        one.add("陆乘风");
        one.add("曲灵风");
        one.add("武眠风");
        one.add("冯默风");
        one.add("罗玉风");
        List<String> two = new ArrayList<>();
        two.add("宋远桥");
        two.add("俞莲舟");
        two.add("俞岱岩");
        two.add("张松溪");
        two.add("张翠山");
        two.add("殷梨亭");
        two.add("莫声谷");

        //获取Stream流
        Stream<String> stream1 = one.stream();
        Stream<String> stream2 = two.stream();

        //1.one只要名字是3个字的人
        //2.筛选后只要前6个
        Stream<String> stringStream1 = stream1.filter((String s) -> {
            return s.length() == 3;
        }).limit(6);

        //3.two只要姓张的
        //4.筛选后不要前1个人
        Stream<String> stringStream2 = stream2.filter((String s) -> {
            return s.startsWith("张");
        }).skip(1);

        //5.两个队伍合并为一个队伍
        Stream.concat(stringStream1, stringStream2).map((String name) -> {
            return new Student(name);
        }).forEach((s) -> {
            System.out.println(s);
        });

    }
}

class Student {
    private String name;

    public Student() {
    }

    public Student(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return " Student {name='" + name + "'}";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}